Skip to content

Conversation

@hendoxc
Copy link
Contributor

@hendoxc hendoxc commented Jan 5, 2026

  • Adds chipingress batching client
  • Adds unit-tests

Copilot AI review requested due to automatic review settings January 5, 2026 21:58
@hendoxc hendoxc requested a review from a team as a code owner January 5, 2026 21:58
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

👋 hendoxc, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a batching client for chipingress that collects CloudEvent messages and sends them in batches based on configurable size and timeout triggers. The implementation provides non-blocking message queuing with configurable concurrency control.

Key changes:

  • Implements a BatchClient with configurable batch size, timeout, buffer size, and concurrency limits
  • Provides asynchronous batch processing with proper context cancellation and shutdown handling
  • Includes comprehensive unit tests covering batch triggers, edge cases, and concurrent operations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/chipingress/batch/client.go Implements the core BatchClient with Start/Stop lifecycle, message queuing, and batch sending logic with configurable options
pkg/chipingress/batch/client_test.go Provides comprehensive test coverage for client initialization, message queuing, batch sending, and various trigger scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

✅ API Diff Results - No breaking changes


📄 View full apidiff report

@hendoxc hendoxc force-pushed the INFOPLAT-3099-chip-ingress-batching branch from e705b9f to 703498f Compare January 5, 2026 22:12
Comment on lines +52 to +53
result := make([]*messageWithCallback, len(b.messages))
copy(result, b.messages)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could clone here:

Suggested change
result := make([]*messageWithCallback, len(b.messages))
copy(result, b.messages)
result := slices.Clone(b.messages)

copy(result, b.messages)

// Reset the internal slice
b.messages = b.messages[:0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to consider freeing this memory in some cases so an outlier capacity doesn't leave a large buffer in the background indefinitely?

Comment on lines +70 to +72
result := make([]*messageWithCallback, len(b.messages))
copy(result, b.messages)
return result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result := make([]*messageWithCallback, len(b.messages))
copy(result, b.messages)
return result
return slices.Clone(b.messages)

batchInterval time.Duration
maxPublishTimeout time.Duration
messageBuffer chan *messageWithCallback
shutdownChan chan struct{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use a services.StopChan, then you can derive contexts from it instead of using context.Background():

Suggested change
shutdownChan chan struct{}
shutdownChan services.StopChan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants